package BookManagement.operation;

import BookManagement.book.Book;
import BookManagement.book.Bookshelf;

import java.util.Scanner;

public class AddBook implements IBusinessOperation{
    @Override
    public void work(Bookshelf bookshelf) {
        System.out.println("添加图书……");
        Scanner scan = new Scanner(System.in);

        System.out.println("请输入要添加的书籍名称：");
        String name = scan.nextLine();


        System.out.println("请输入要添加的书籍作者：");
        String author = scan.nextLine();


        System.out.println("请输入要添加的书籍价格：");
        int price = scan.nextInt();
        scan.nextLine();

        System.out.println("请输入要添加的书籍类型：");
        String type = scan.nextLine();

        //构建书籍对象
        Book book = new Book(name,author,price,type);

        //当前书籍的数量，就是要插入书籍的下标
        bookshelf.books[bookshelf.book_umber] = book;

        bookshelf.book_umber += 1;
        System.out.println("添加成功！");

    }
}
